//
//  LJJNavigationController.m
//  shopTest
//
//  Created by 梁佳佳 on 2016/11/14.
//  Copyright © 2016年 梁佳佳. All rights reserved.
//

#import "LJJNavigationController.h"

@interface LJJNavigationController ()

@end

@implementation LJJNavigationController

+ (void)initialize
{
    //拿到navigationBar
    UINavigationBar *navigationBar = [UINavigationBar appearance];
    [navigationBar setBackgroundImage:[UIImage imageNamed:@"nav_backImage"] forBarMetrics:UIBarMetricsDefault];
    [navigationBar setTitleTextAttributes:@{
                                            NSForegroundColorAttributeName : [UIColor blackColor],
                                            NSFontAttributeName : [UIFont boldSystemFontOfSize:20.0f]
                                            }];
    navigationBar.shadowImage = [UIImage new];
}

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
#pragma mark -
#pragma mark - method
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    
    if (self.childViewControllers.count) {
        UIButton *backBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [backBtn setBackgroundImage:[UIImage imageNamed:@"详情界面返回按钮"] forState:(UIControlStateNormal)];
        [backBtn addTarget:self action:@selector(returnViewController) forControlEvents:(UIControlEventTouchUpInside)];
        backBtn.frame = CGRectMake(0, 0, 30, 30);
        UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithCustomView:backBtn];
        viewController.navigationItem.leftBarButtonItem = item;
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}

- (void)returnViewController{
    [self popViewControllerAnimated:YES];
}

@end
